import { Colors } from '../content'
interface IProps {
  title: string;
  pid: string;
  cid: string;
  pic: string;
  isNew?: boolean;
}
const PostItem = (props: IProps) => {
  const { cid, title, pid, pic } = props;
  const onPage = (pid: string) => {
    location.href = `/post?cid=${cid}&id=${pid}`
  }
  const onLast = (e: any) => {
    e.preventDefault();
    e.stopPropagation();
    onPage('latest')
  }
  return (
    <div style={`width:48%;display:flex;flex-direction:column;padding:16px;margin-top:16px;box-sizing:border-box;border-radius:12px;background:#${Colors[Math.floor(Math.random()*Colors.length)]}`} onClick={() => onPage(pid)}>
      <div style="display:flex;align-items:center;">
        <img src={`/imgs/${pic}`} style="width:30px;height:30px;" />
        <span class='iconfont icon-new' onClick={onLast} style="margin-left:auto;font-size:30px;"></span>
      </div>
      <div style="font-size:14px;margin-top:8px;font-weight:bold;">{title}</div>
      <div style="margin-top:6px;font-size:12px;">第{pid}期</div>
    </div>
  );
};
export default PostItem;
